package vo

import (
	"dc-news-admin-api/common/global/consts"
	"dc-news-admin-api/common/utils"
	"dc-news-admin-api/entity"
)

type SetUserMuteStatusReq struct {
	IsMuted bool `json:"is_muted"`
}

type GerUserListResp struct {
	Code       int    `json:"code"`
	Msg        string `json:"msg"`
	Pagination struct {
		Page  int `json:"page"`
		Limit int `json:"limit"`
		Total int `json:"total"`
	} `json:"pagination"`
	Data []struct {
		Id       int    `json:"id"`
		UserName string `json:"user_name"`
		NickName string `json:"nick_name"`
		Email    string `json:"email"`
		Avatar   string `json:"avatar"`
		IsMuted  bool   `json:"isMuted"`
	} `json:"data"`
}

func NewGetUserListResp(users []entity.User, p *utils.Pagination) *GerUserListResp {
	resp := &GerUserListResp{
		Code: consts.OKCode,
		Msg:  "ok",
		Pagination: struct {
			Page  int `json:"page"`
			Limit int `json:"limit"`
			Total int `json:"total"`
		}{
			Page:  p.Page,
			Limit: p.Size,
			Total: p.Total,
		},
		Data: nil,
	}
	for _, user := range users {
		resp.Data = append(resp.Data, struct {
			Id       int    `json:"id"`
			UserName string `json:"user_name"`
			NickName string `json:"nick_name"`
			Email    string `json:"email"`
			Avatar   string `json:"avatar"`
			IsMuted  bool   `json:"isMuted"`
		}{
			Id:       user.ID,
			UserName: user.Username,
			NickName: user.Nickname,
			Email:    user.Email,
			Avatar:   user.Avatar,
			IsMuted:  user.IsMuted,
		})
	}
	return resp
}
